/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bash.carrep.ui;

import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HorizontalLayout;

/**
 *
 * @author bash
 */
public class ToolbarAdmin extends HorizontalLayout implements Button.ClickListener {

    CarrepApplication app;
    Button cl;
    Button users;
    Button numMat;
    Button logout, catPM, typeDeclar, modAuto;

    public ToolbarAdmin(CarrepApplication app) {
        this.app = app;
        cl = new Button("Credit Levels", this);
        users = new Button("Utilisateurs", this);
        numMat = new Button("Numéros Imatriculation", this);
        logout = new Button("Déconnexion", this);

        catPM = new Button("Categorie PM", this);
        typeDeclar = new Button("Type Déclar.", this);
        modAuto = new Button("Modèles Auto", this);

        //setSizeFull();
        setSpacing(true);

        addComponent(cl);
        addComponent(users);
        addComponent(typeDeclar);
        addComponent(catPM);
        addComponent(modAuto);
        addComponent(numMat);
        addComponent(logout);
    }

    @Override
    public void buttonClick(ClickEvent event) {

        Button source = event.getButton();

        if (source.equals(cl)) {
            app.showCreditLevelView();
        } else if (source.equals(logout)) {
            app.close();
        } else if (source.equals(users)) {
            app.showUsersView();
        }
          else if (source.equals(catPM)) {
            app.showTyPePMView();
        }
    }
}
